<?php


namespace App\Service;


class ApiResponse
{
    public static function success($data = null, string $message = null){
        $result = [
            'code'    => 0,
            'message' => $message??'',
        ];

        if (!is_null($data)) {
            $result['data'] = $data;
        }
        return $result;
    }

    public static function fail(string $message, $code = -1)
    {
        return [
            'code'       => $code,
            'message'    => $message,
        ];
    }
}
